//
//  HJIconTitleButton.m
//  KaiChat
//
//  Created by lx on 2024/1/12.
//

#import "TJIconTitleCellButton.h"

 

@implementation TJIconTitleCellButton {
    UIImageView *__weak _iconImageView;
    UIImageView *__weak _arrowImageView;
    UIView *__weak _lineView;
    UILabel *__weak _titleLabel;
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self settingSubView];
    }
    return self;
}

- (void)settingSubView {

    _iconImageView = [UIImageView addToView:self];
    [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(15);
        make.centerY.offset(0);
    }];
    
    _titleLabel = [UILabel lableWithSuperView:self font:UIFontMake(14) color:UIColor.whiteColor title:nil textAlignment:NSTextAlignmentLeft];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(50);
        make.centerY.offset(0);
    }];
 
    _lineView = [UIView addToView:self];
    _lineView.backgroundColor = [UIColor.tj_CCCCCCColor colorWithAlphaComponent:0.2];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.inset(15);
        make.bottom.offset(0);
        make.height.offset(lineHeight);
    }];
    
    _arrowImageView = [UIImageView addToView:self];
    _arrowImageView.image = [UIImage imageNamed:@"cell_arrow"];
    [_arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.inset(16);
        make.centerY.offset(0);
    }];
 
}

- (void)setModel:(TJCellModel *)model {
    _model = model;

    _arrowImageView.hidden = !model.showArrow;
    _iconImageView.image = [UIImage imageNamed:model.iconName];
    _titleLabel.text = model.text;
    _lineView.hidden = !model.showLine;
}
 

@end

